require(['./config'],()=>{
    require(['template','swiper','header','footer'],(template,Swiper)=>{
        class Index{
            constructor(){
             this.getCategory()
             this.getGoods()
             this.banner()

            }
            getCategory(){
                $.get('/libs/json/homeCategory.json',resp=>{
                    this.renderCategory(resp)
                })
            }
              //发送请求，拿到json数据，进一步渲染
            renderCategory(list){     
            const html=  template('goodsList',{list })
            $('#goods').html(html)
              }

            getGoods(){
                $.get('/libs/json/goodsList.json',resp=>{
                    this.renderGoods(resp)
                })
            }
            
            renderGoods(list){
                 const data =  template('goodGroup',{list})
                $('#goodsLi').html(data)
            }
            
            banner(){
               new Swiper('.swiper-container',{           
                  navigation: {
                    nextEl: '.swiper-button-next',
                    prevEl: '.swiper-button-prev',
                  },
                  pagination: {
                    el: '.swiper-pagination',
                    clickable:true,
                  },
                   direction:'horizontal',
                   autoplay:true,
                   loop:true,
               })
            }
       
        }
        new Index()
    })

})